import React, { Component } from "react";
import { Button, Modal, Form, Radio, Input } from "antd";
import axios from "axios";
// import {connect} from "react-redux"
// import {setVisible} from "../actions"
const FormItem = Form.Item;
const RadioGroup = Radio.Group;

// @connect(store => {
//     return {
//         visible: store.componentReducer.visible,
//         student: store.studentsReducer.student
//     };
// })
// @Form.create({
//     mapPropsToFields(props) {
//         return {
//             name: Form.createFormField({
//                 value: props.student.name
//             }),
//             age: Form.createFormField({
//                 value: props.student.age
//             }),
//             gender: Form.createFormField({
//                 value: props.student.gender
//             })
//         };
//     }
// })
class StudentsUpdate extends Component {
    formRef = React.createRef();
    constructor() {
        super();
    }
    openAdd = () => {};
    handleOk = () => {
        // let { getFieldsValue } = this.props.form;
        // console.log(getFieldsValue());
        // axios({
        //     method: "put",
        //     url: "/students/" + this.props.student._id,
        //     data: getFieldsValue()
        // }).then(() => {
        //     this.props.show();
        //     this.props.closeUpdate();
        // });
    };
    handleCancel = () => {
        // this.props.dispatch(setVisible(false))
        this.props.closeUpdate();
    };
    
    render() {
        // const { getFieldDecorator } = this.props.form;

        const formItemLayout = {
            labelCol: {
                xs: { span: 24 },
                sm: { span: 4 }
            },
            wrapperCol: {
                xs: { span: 24 },
                sm: { span: 20 }
            }
        };
       
        return (
            <div>
                <Modal
                    title="修改学生"
                    visible={this.props.visible}
                    onOk={this.handleOk}
                    onCancel={this.handleCancel}
                >
                    <Form ref={this.formRef} initialValues={this.props.students} onValuesChange={() => {console.log(123)}}> 
                        <FormItem {...formItemLayout} hasFeedback label="姓名">
                            <Input />
                        </FormItem>
                        <FormItem {...formItemLayout} label="年龄">
                            <Input />
                        </FormItem>
                        <FormItem {...formItemLayout} label="性别">
                            <RadioGroup>
                                    <Radio value="男">男</Radio>
                                    <Radio value="女">女</Radio>
                                </RadioGroup>
                           
                        </FormItem>
                    </Form>
                </Modal>
            </div>
        );
    }
}

// export default connect(store => {
//     return {
//         visible: store.componentReducer.visible
//     };
// })(
//     Form.create({
//         mapPropsToFields(props) {
//             return {
//                 name: Form.createFormField({
//                     value: props.student.name
//                 }),
//                 age: Form.createFormField({
//                     value: props.student.age
//                 }),
//                 gender: Form.createFormField({
//                     value: props.student.gender
//                 })
//             };
//         }
//     })(StudentsUpdate)
// );

export default StudentsUpdate;